import { createSlice } from "@reduxjs/toolkit";
import useTheme from "@/hooks/useTheme";

export const globalSlice = createSlice({
  name: "counter",
  initialState: {
    theme: "default", // default dark
  },
  reducers: {
    changeTheme: (state, action) => {
      state.theme = action.payload;
      useTheme(state.theme);
    },
  },
});

// 每个 case reducer 函数会生成对应的 Action creators
export const { changeTheme } = globalSlice.actions;
export default globalSlice.reducer;
